local skel = fk.CreateSkill{
  name = "tea__deqing",
}
--local U = require "packages/utility/utility"
Fk:loadTranslationTable{
  ["tea__deqing"] = "德清",
  [":tea__deqing"] = "摸牌阶段或弃牌阶段，你可以改为和一名其他角色拼点：若你赢，你将手牌摸至体力上限；若你没赢，其对你造成1点伤害。",
  ["#tea__deqing-invoke"] = "德清：你可以与一名角色拼点",
}
---@type TrigSkelSpec<PhaseFunc>
local deqing = {
  mute = true,
  can_trigger = function (self, event, target, player, data)
    return player == target and player:hasSkill(skel.name) and table.contains({ Player.Draw, Player.Discard }, player.phase) and table.find(player.room.alive_players, function(p)
      return player:canPindian(p)
    end)
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getOtherPlayers(player), function(p)
      return player:canPindian(p)
    end)
    local to = room:askToChoosePlayers(player, {
      min_num = 1,
      max_num = 1,
      targets = targets,
      skill_name = skel.name,
      prompt = "#tea__deqing-invoke"
    })
    if #to == 1 then
      event:setCostData(self, { to = to[1] })
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:notifySkillInvoked(player, skel.name, "special")
    player:broadcastSkillInvoke(skel.name, table.random{1, 2})
    local to = event:getCostData(self).to ---@type ServerPlayer
    data.phase_end = true
    local pindian = player:pindian({to}, skel.name)
    if not player.dead then
      if pindian.results[to].winner == player then
        room:doAnimate("InvokeSkill", {
          name = skel.name,
          player = player.id,
          skill_type = "drawcard",
        })
        player:broadcastSkillInvoke(skel.name, 3)
        if #player:getCardIds("h") < player.maxHp then
          player:drawCards(player.maxHp - #player:getCardIds("h"), skel.name)
        end
      else
        room:doAnimate("InvokeSkill", {
          name = skel.name,
          player = player.id,
          skill_type = "negative",
        })
        player:broadcastSkillInvoke(skel.name, 4)
        room:damage{
          from = to,
          to = player,
          damage = 1,
          skillName = skel.name
        }
      end
    end
  end
}
skel:addEffect(fk.EventPhaseStart, deqing)
-- Fk.generals["mouxusheng"]:addSkill(skel.name)
return skel